import 'normalize.css';
import './assets/base.css'

import { createApp } from 'vue'
import { createPinia } from 'pinia'

import App from './App.vue'
import router from './router'

import ElementPlus from 'element-plus'
import zhCn from 'element-plus/es/locale/lang/zh-cn'

import JsonExcel from 'vue-json-excel3';

//import.meta.glob 是 vite 提供的语法，用于导入指定目录下的所有模块
const directives = import.meta.glob('./directives/*.ts', {
    eager: true,
    import: 'default'
});
import type { Directive } from 'vue'

const app = createApp(App)

app.use(createPinia())
app.use(router)
app.use(ElementPlus, {
    locale: zhCn,
})

app.component('downloadExcel', JsonExcel);

//批量注册 directives 中的自定义指令
for (const key in directives) {
    app.directive(key.replace('./directives/', '').replace('.ts', ''), directives[key] as Directive)
}

app.mount('#app')
